package org.fujene.structure;

public class HashID implements Comparable<HashID> {
	// public byte flags;
	public long hash;
	public long ID;

	public HashID(long hash, long ID) {
		this.hash = hash;
		this.ID = ID;
	}

	public String toString() {
		return String.format("[0x%08x, 0x%016x]", hash, ID);
	}

	public boolean equals(HashID q) {
		if (q.hash == this.hash && q.ID == this.ID)
			return true;
		return false;
	}

	@Override
	public int compareTo(HashID query) {
		if (query.hash != this.hash) {
			return (int)(this.hash - query.hash);
		} else {
			if (query.ID != this.ID) {
				return ((this.ID - query.ID > 0) ? 1 : -1);
			} else {
				return 0;
			}
		}
	}
	
	public int compareToID(HashID query){
		if (query.ID != this.ID) {
			return ((this.ID - query.ID > 0) ? 1 : -1);
		} else {
			return 0;
		}
	}}
